#!/usr/bin/env python
#coding=utf-8
"""
类的继承练习
"""
class ClassMember:
	def __init__(self, name, age):
		self.name = name
		self.age = age

	def tell(self):
		print "name is", self.name, "age is", self.age

#继承父类
class Teacher(ClassMember):
	#增加自己的一个salary属性
	def __init__(self, name, age, salary):
		#调用父类的init方法传递name和age属性,将子类的变量赋给父类，使其拥有父类全部的属性,所以子类的参数不需要和父类完全相同
		ClassMember.__init__(self, name, age)
		self.salary = salary

	#这时候父类也有一个tell方法，子类和父类同时有同一个方法的时候，子类方法优先
	def tell(self):
		print "teacher salary", self.salary

#继承父类
class Student(ClassMember):
	def __init__(self, name, age, mark):
		ClassMember.__init__(self, name ,age)
		self.mark = mark

	def Mark(self):
		print "student mark", self.mark

alex = Teacher(name='alex', age='18', salary=50000)
alex.tell()

mingmings = Student(name='mingmings', age='25', mark=50)
mingmings.Mark()
